<template>
  <div class="w-100 h-100 yjzybz">
    <div class="w-100">
      <div
        v-if="list"
        class="item"
        v-for="(item, index) in list"
        :key="item.label"
        :class="'bg' + index"
        :style="{}"
      >
        <div class="itemLabel">{{ item.label }}</div>
        <div class="child" v-for="child in item.children" :key="item.label">
          <span class="value" :style="{ color: item.color }">
            {{ child.value }}
          </span>
          <span>{{ child.unit || item.unit }}</span>
          <span class="label">{{ child.label }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import bg1 from "@/assets/image/underGround/dsx1.png";
import bg2 from "@/assets/image/underGround/dsx2.png";
import bg3 from "@/assets/image/underGround/dsx3.png";

const baseList = [
  {
    label: "人员保障",
    color: "#00F3FF",
    unit: "名",
    children: [
      { label: "医护人员" },
      { label: "警员" },
      { label: "专家" },
      { label: "志愿者" },
    ],
  },
  {
    label: "物质保障",
    color: "#00FFB1",
    unit: "个",
    children: [
      { label: "水", unit: "吨" },
      { label: "防护用品" },
      { label: "防毒设备", unit: "件" },
      { label: "医疗在库" },
      { label: "出库" },
    ],
  },
  {
    label: "车辆保障",
    color: "#FFE6BE",
    unit: "辆",
    children: [
      { label: "警车" },
      { label: "消防车" },
      { label: "洒水车" },
      { label: "救护车" },
    ],
  },
];

const jsonData: any = inject("jsonData");
const current = computed(() => {
  let data = [];
  try {
    data = jsonData.value.underJsc.yjzybz;
  } catch (error) {}

  return data;
});

const list = ref();

watch(
  () => current.value,
  (val) => {
    if (val) {
      try {
        const arr = baseList.map((item, index) => {
          item.children = item.children.map((child, i) => {
            return {
              ...child,
              value: val[index][i],
            };
          });

          return item;
        });
        list.value = arr;
      } catch (error) {}
    }
  }
);
</script>

<style lang="less" scoped>
.yjzybz {
  display: flex;
  align-items: center;
  justify-content: center;
}
.item {
  height: 65px;
  display: flex;
  align-items: center;
  padding-left: 120px;
  & ~ .item {
    margin-top: 36px;
  }
}
.itemLabel {
  margin-right: 20px;
}
.child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  position: relative;
  .label {
    margin-right: 10px;
  }

  .value {
    font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
    font-weight: bold;
  }
  & ~ .child {
    &::before {
      content: "";
      width: 1px;
      height: 100%;
      position: absolute;
      left: 0;
      top: 0;
      background: linear-gradient(
        180deg,
        rgba(0, 243, 255, 0) 0%,
        #00f3ff 47%,
        rgba(0, 243, 255, 0) 100%
      );
    }
  }
}
.bg0 {
  background: url("@/assets/image/underGround/yjzy_1.png") no-repeat left center;
  background-size: auto 100%;
}
.bg1 {
  background: url("@/assets/image/underGround/yjzy_2.png") no-repeat left center;
  background-size: auto 100%;
}
.bg2 {
  background: url("@/assets/image/underGround/yjzy_3.png") no-repeat left center;
  background-size: auto 100%;
}
</style>
